-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang][bytecode] Diagnose heap-allocated array elem pointers... #137523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
... as "pointer to subobject".
|
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes... as "pointer to subobject". Full diff: https://github.com/llvm/llvm-project/pull/137523.diff 2 Files Affected:
diff --git a/clang/lib/AST/ByteCode/EvaluationResult.cpp b/clang/lib/AST/ByteCode/EvaluationResult.cpp
index d603e08c7bb4d..f59612bf00015 100644
--- a/clang/lib/AST/ByteCode/EvaluationResult.cpp
+++ b/clang/lib/AST/ByteCode/EvaluationResult.cpp
@@ -230,8 +230,9 @@ bool EvaluationResult::checkReturnValue(InterpState &S, const Context &Ctx,
assert(B->getDescriptor());
assert(B->getDescriptor()->asExpr());
+ bool IsSubobj = !Ptr.isRoot() || Ptr.isArrayElement();
S.FFDiag(Info, diag::note_constexpr_dynamic_alloc)
- << Ptr.getType()->isReferenceType() << !Ptr.isRoot();
+ << Ptr.getType()->isReferenceType() << IsSubobj;
S.Note(B->getDescriptor()->asExpr()->getExprLoc(),
diag::note_constexpr_dynamic_alloc_here);
return false;
diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp
index e1b81e9a7963e..3de527c881680 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -619,6 +619,10 @@ namespace std {
}
}
+constexpr int *escape = std::allocator<int>().allocate(3); // both-error {{constant expression}} \
+ // both-note {{pointer to subobject of heap-allocated}} \
+ // both-note {{heap allocation performed here}}
+
/// Specialization for float, using operator new/delete.
namespace std {
using size_t = decltype(sizeof(0));
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/10897 Here is the relevant piece of the build log for the reference |
…m#137523) ... as "pointer to subobject".
... as "pointer to subobject".